Post

Replies

Boosts

Views

Activity

Getting the Locale of the System in iOS
Hi, I use the elbow code to toggle between English and Arabic locale, but the alert message always shows en_QA which is English I guess even when locale changed to Arabic ? why is that ? struct arview: View { @Environment(\.locale) private var locale @State private var showingAlert = false @State private var isLTR: Bool = false @State private var txtValue = "" var body: some View { VStack{ Text("Note Title") TextField("Place Holder", text: $txtValue) Button("Change Locale") { isLTR.toggle() } Button("Show Alert") { showingAlert = true } .alert("Current Locale: \(locale.identifier)", isPresented: $showingAlert) { Button("OK", role: .cancel) { } } } .padding() .environment (\.locale, isLTR ? Locale.init(identifier: "en" ) : Locale.init(identifier: "ar" )) } }
0
0
297
Jan ’24
Adding multi view to NavigationPath in one go
Hi How can we add multi view to NavigationPath in one go like in code below maybe using something like path.append(mobiles.all) ? where all 3 views of mobiles Array get added at once ? Kindest Regards `struct NavigationPathView: View { var mobiles: [Mobiles] = [.init (name: "iPhone", imageName: "folder", color: .mint), .init (name: "Samsung", imageName: "pin", color: .pink), .init (name: "Mac Pro", imageName: "book", color: .gray)] @State var path = NavigationPath() var body: some View { NavigationStack (path: $path) { List { Section ("Platforms") { Button("Go To Platform") { path.append(mobiles.first!) } Button("Go To Mobile") { path.append(mobiles.last!) } Button("Add All Mobiles") { } } } } .navigationDestination(for: Mobiles.self) {mobile in ZStack { mobile.color.ignoresSafeArea() VStack { Image(systemName: mobile.imageName) Label (mobile.name, systemImage: mobile.imageName) .font(.largeTitle).bold().foregroundColor(.white) Button("Go Home") { path.removeLast(path.count) } } } } } }
2
0
377
Dec ’23
NavigationSplitView Collapse Button
Hi, When creating a 3 columns Split View in SwiftUI the second view that resemble the mails list in Apple Mails App have a blue icon at top left corner where when tapped shows the column of Mail boxes such as Inbox, Sent etc. This icon by default when creating the Split View disappears after tapping, it shows the third column and disappear , I would like it to stay so I can show and collapse the first column sam as Apple Mail App. how to do that ? its called back also how to rename it and add icon to it ?
3
0
753
Nov ’23